﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
    <script type="text/javascript" src="../../Content/highlighter/scripts/shCore.js"></script>
    <script type="text/javascript" src="../../Content/highlighter/scripts/shBrushCSharp.js"></script>
    <script type="text/javascript" src="../../Content/highlighter/scripts/shBrushXml.js"></script>
    <link type="text/css" rel="stylesheet" href="../../Content/highlighter/styles/shCore.css" />
    <link type="text/css" rel="stylesheet" href="../../Content/highlighter/styles/shCoreEclipse.css" />
    <script type="text/javascript">SyntaxHighlighter.all();</script>
</head>
<body>
    <h3>CopyHelper</h3>
    <p>
        我们经常会遇到两个不同的数据库实体类之间需要复制信息，但是手动复制字段太多，而且容易出错。
        于而CopyHelper类就解决了该问题。
        实体类中只能含有由以下类型组成的字段和属性。<br />
        SByte,Byte,Int16,UInt16,Int32,UInt32,Int64,UInt64,Boolean,<br />
        Char,Decimal,Double,Single,DateTime,DateTimeOffset，<br />
        SByte?,Byte?,Int16?,UInt16?,Int32?,UInt32?,Int64?,UInt64?,Boolean?,<br />
        Char?,Decimal?,Double?,Single?,DateTime?,DateTimeOffset?<br /><br />
        <pre class="brush:csharp;">
            public class UserA
            {
                public int id {get;set;}
                public string name {get;set;}
                public string pwd {get;set;}
            }
            public class UserB
            {
                public int id {get;set;}
                public string name {get;set;}
                public string pwd {get;set;}
            }
        </pre>
        <pre class="brush:csharp;">
            using NFinal.Emit;
            public class IndexController : BaseController
            {
                public void Index()
                {
                    UserA userA=new UserA();
                    userA.id=1;
                    userA.name="Lucas";
                    userA.pwd="123456";
                    UserB userB=new UserB();
                    //复制操作
                    userB = CopyHelper.CopyEmit(userA,userB);
                    this.Write(userB.id);
                    this.Write(userB.name);
                }
            }
        </pre>
    </p>
</body>
</html>